package com.Controller;

import com.Service.StudentService;
import com.entity.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/subject")
public class StudentController {
    @Autowired
    private StudentService studentService;

    /**
     * 查询
     * @param student
     * @return
     */
    @RequestMapping(value = "/queryStudent",method = RequestMethod.GET)
    public List<Student> queryStudent(Student student){
        return studentService.queryStudent(student);
    }

    /**
     * 新增
     * @param student
     * @return
     */
    @RequestMapping(value = "/addStudent",method = RequestMethod.POST)
    public int addStudent(@RequestBody Student student){
        return studentService.addStudent(student);
    }

    /**
     * 删除
     * @param id
     * @return
     */
    @RequestMapping(value = "/delStudent/{id}",method = RequestMethod.DELETE)
    public int delStudent(@PathVariable int id){
        return studentService.delStudent(id);
    }

    /**
     * 修改
     * @param student
     * @return
     */
    @RequestMapping(value = "/updateStudent/{id}",method = RequestMethod.PUT)
    public int updateStudent(@RequestBody Student student,@PathVariable int id){
        student.setStuId(id);
        return studentService.updateStudent(student);
    }
}
